//*****************************************************************************
//File: ComputeResult.java
//This Java Source File was implemented in in order to compute a single result 
//column of matrix multiplication.
//*****************************************************************************

/**
 * Class ComputeResult provides an object for calculating a single result
 * column of multiplying two matrices. This object is created on receiving
 * the input matrices from the Master on message listener.
 *
 * @author  Vivek Narang (vsn6751@rit.edu)
 * @version 05-May-2012
 */
public class ComputeResult {
	
	public ResultantColumn computeResult(MatrixInput matrix,
			int[] colMatrix, int colId) {
		// Get the complete 1st matrix 
		int input1[][] = matrix.getInput1();
		ResultantColumn rc;
		
		int resultCol[] = new int[input1[0].length];
		
		int sum = 0;
		for(int i = 0; i < input1.length; i++) {
			for(int j = 0; j < input1[i].length; j++) {
				sum += input1[i][j] * colMatrix[j];
			}
			resultCol[i] = sum;
			sum = 0;
		}
		rc = new ResultantColumn(colId, resultCol);
		return rc;
	}
}